<template>
  <div>
    <h3>我是登录页</h3>
    <input v-model="user" type="text" placeholder="请输入账号">
    <input v-model="pwd" type="password" placeholder="请输入密码">

    <!-- 需求是：只有账号是admin，并且密码是123456才正确才跳转 -->
    <!-- 声明式导航是只要一点就能跳转，所以这里肯定不能用 -->
    <!-- <router-link to="/home">登录</router-link> -->
    <button @click="login">登录</button>
  </div>
</template>

<script>
export default {

    data() {
        return {
            user: '',
            pwd: ''
        }
    },

    methods: {

        login () {
            if (this.user == 'admin' && this.pwd == '123456') {

                this.$router.push('/home')
            }else {
                alert('账号或密码错误')
            }
        }
    }
}
</script>

<style>

</style>